package cn.com.sixboy.entity;

import java.io.Serializable;
import java.util.List;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.TableGenerator;

/**
 * @author Sam.Zheng <zcl1866@sina.com>
 * @date 2013-5-4 14:12:55
 * @version <v0.1>
 * @copyright SixBoy
 */
@Entity
@Table(name = "s_class")
@NamedQueries(
        { 
            @NamedQuery(name = "findAllClasses", query = "select c from Class c order by c.id"),
            @NamedQuery(name = "findAllClassesByName", query = "select c from Class c where c.className like :className order by c.id")
        }
     )
public class Class implements Serializable {
	@Id
	@TableGenerator(name = "s_class", table = "sys_generator", pkColumnName = "key_name", pkColumnValue = "STU_ID", valueColumnName = "key_value", initialValue = 1, allocationSize = 1)
	@GeneratedValue(strategy = GenerationType.TABLE, generator = "s_class")
	private int id;

	@Column(length = 30, name = "c_name")
	private String className;

	@OneToMany(mappedBy = "s_class",fetch= FetchType.LAZY,cascade= CascadeType.REFRESH)
	private List<Student> students;

	public int getId() {
		return id;
	}

	public void setId(int id) {
		this.id = id;
	}

	public String getClassName() {
		return className;
	}

	public void setClassName(String className) {
		this.className = className;
	}

	public List<Student> getStudents() {
		return students;
	}

	public void setStudents(List<Student> students) {
		this.students = students;
	}

}
